package com.ky.manage.activity;

import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import android.widget.TextView;

import com.ky.manage.BaseApplication;
import com.ky.manage.R;
import com.ky.manage.base.BaseActivity;
import com.ky.manage.model.LoginUserInfo;
import com.ky.manage.utils.ImageLoader.ImageLoaderUtils;

/**
 * 二维码页
 */
public class EwCodeActivity extends BaseActivity {
    private LoginUserInfo mLoginUserInfo;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_ew_code;
    }

    private void getCurLoginUserInfo() {
        mLoginUserInfo = BaseApplication.getLoginUserInfo();
        if (null == mLoginUserInfo) {
            mLoginUserInfo = new LoginUserInfo();
        }
    }

    @Override
    protected void initView() {
        findTextView(R.id.page_title_tv, "我的二维码");
        findView(R.id.back_iv, v -> {
            finish();
        });

        getCurLoginUserInfo();

        ImageView userHeadIv = findView(R.id.user_head_iv);
        ImageLoaderUtils.loadImage(this, mLoginUserInfo.userHeadUrl, userHeadIv);
        TextView userNameTv = findTextView(R.id.user_name_tv, mLoginUserInfo.userName);
        Drawable drawable = getResources().getDrawable("1".equals(mLoginUserInfo.sex) ?
                R.mipmap.woman : R.mipmap.man, null);
        userNameTv.setCompoundDrawablesWithIntrinsicBounds(null,
                null, drawable, null);
        findTextView(R.id.ew_code_tv, mLoginUserInfo.ewCodeValue);
        findTextView(R.id.address_tv, mLoginUserInfo.addressRegion);
        ImageView erCodeIv = findView(R.id.ew_code_iv);
        ImageLoaderUtils.loadImage(this, mLoginUserInfo.ewCodeUrl, erCodeIv);
    }

    @Override
    protected void initData() {

    }
}